import logging
import os
import sys

BASE_DIR = os.path.abspath(os.path.dirname(__file__))

# SQLite URI 兼容
WIN = sys.platform.startswith('win')
if WIN:
    PREFIX = 'sqlite:///'
else:
    PREFIX = 'sqlite:////'

# 日志路径
LOG_PATH = os.path.join(BASE_DIR, 'logs')

# 日志级别
LOG_LEVEL = logging.INFO


class BaseConfig:
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    APP_NAME = "MAIN-APP"


class DevelopmentConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = PREFIX + os.path.join(BASE_DIR, 'data-dev.db')
    # FLASK_ADMIN_SWATCH = 'Readable'  # https://bootswatch.com/3/ 可选各种主题
    BABEL_DEFAULT_LOCALE = 'zh_CN'


class ProductionConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL', PREFIX + os.path.join(BASE_DIR, 'data-product.db'))


config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
}

if __name__ == '__main__':
    print(BASE_DIR)
